package com.whisper.application.service.controller;

import com.whisper.application.service.domain.VrUser;
import com.whisper.application.service.service.IVrUserService;
import com.whisper.common.annotation.Log;
import com.whisper.common.annotation.PageQuery;
import com.whisper.common.core.controller.BaseController;
import com.whisper.common.enums.BusinessType;
import com.whisper.common.excel.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 前台用户信息Controller
 * 
 * @author whisper
 * @date 2024-01-07
 */
@RestController
@RequestMapping("/service/user")
public class VrUserController extends BaseController
{
    @Autowired
    private IVrUserService vrUserService;

    /**
     * 查询前台用户信息列表
     */
    @PageQuery
    @PreAuthorize("@ss.hasPermi('service:user:list')")
    @GetMapping("/list")
    public List<VrUser> list(VrUser vrUser)
    {
        return vrUserService.selectVrUserList(vrUser);
    }

    /**
     * 导出前台用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('service:user:export')")
    @Log(title = "前台用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VrUser vrUser)
    {
        List<VrUser> list = vrUserService.selectVrUserList(vrUser);
        ExcelUtil<VrUser> util = new ExcelUtil<VrUser>(VrUser.class);
        util.exportExcel(response, list, "前台用户信息数据");
    }

    /**
     * 获取前台用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:user:query')")
    @GetMapping(value = "/{id}")
    public VrUser getInfo(@PathVariable("id") Long id)
    {
        return vrUserService.selectVrUserById(id);
    }

    /**
     * 新增前台用户信息
     */
    @PreAuthorize("@ss.hasPermi('service:user:add')")
    @Log(title = "前台用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public void add(@RequestBody VrUser vrUser)
    {
        vrUserService.insertVrUser(vrUser);
    }

    /**
     * 修改前台用户信息
     */
    @PreAuthorize("@ss.hasPermi('service:user:edit')")
    @Log(title = "前台用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public void edit(@RequestBody VrUser vrUser)
    {
        vrUserService.updateVrUser(vrUser);
    }

    /**
     * 删除前台用户信息
     */
    @PreAuthorize("@ss.hasPermi('service:user:remove')")
    @Log(title = "前台用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public void remove(@PathVariable Long[] ids)
    {
        vrUserService.deleteVrUserByIds(ids);
    }
}
